<HTML>
<HEAD>
<TITLE>[Chapter 6] 6.2 Panel</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 14:36:45 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch06_01.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 6<br>Containers</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch06_03.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JAWT-CH-6-SECT-2">6.2 Panel</A></h2>

<P CLASS=para>
The <tt CLASS=literal>Panel</tt> class provides a 
generic container within an existing display area. It is the simplest of 
all the containers. When you load an applet into Netscape Navigator or 
an <I CLASS=emphasis>appletviewer</I>, you have a <tt CLASS=literal>Panel</tt> 
to work with at the highest level. 

<P CLASS=para>
A <tt CLASS=literal>Panel</tt> has no physical appearance. 
It is just a rectangular display area. The default <tt CLASS=literal>LayoutManager</tt> 
of <tt CLASS=literal>Panel</tt> is <tt CLASS=literal>FlowLayout</tt>; 
<tt CLASS=literal>FlowLayout</tt> is described in 
<A HREF="ch07_02.htm#JAWT-CH-7-SECT-2">FlowLayout</A>. 

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JAWT-CH-6-SECT-2.1">Panel Methods</A></h3>Constructors

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>public Panel () </I><br>
<DD>

<P CLASS=para>
The first constructor creates a <tt CLASS=literal>Panel</tt> 
with a <tt CLASS=literal>LayoutManager</tt> of <tt CLASS=literal>FlowLayout</tt>. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public Panel (LayoutManager layout) <img src="gifs/bstar.gif" alt="(New)" border=0> </I><br>
<DD>

<P CLASS=para>
This constructor allows you to set the initial <tt CLASS=literal>LayoutManager</tt> 
of the new <tt CLASS=literal>Panel</tt> to <tt CLASS=literal>layout</tt>. 
If <tt CLASS=literal>layout</tt> is <tt CLASS=literal>null</tt>, 
there is no <tt CLASS=literal>LayoutManager</tt>, and 
you must shape and position the components within the <tt CLASS=literal>Panel</tt> 
yourself. </DL>
Miscellaneous methods

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>public void addNotify ()  </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>addNotify()</tt> method creates 
the <tt CLASS=literal>Panel</tt> peer. If 
you override this method, first call <tt CLASS=literal>super.addNotify()</tt>, 
then add your customizations for the new class. Then you can do everything 
you need with the information about the newly created peer. </DL>
</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JAWT-CH-6-SECT-2.2">Panel Events</A></h3>

<P CLASS=para>
In Java 1.0, a <tt CLASS=literal>Panel</tt> 
peer generates all the events that are generated by the <tt CLASS=literal>Component</tt> 
class; it does not generate events that are specific to a particular type 
of component. That is, it generates key events, mouse events, and focus 
events; it doesn't generate action events or list events. If an event 
happens within a child component of a <tt CLASS=literal>Panel</tt>, 
the target of the event is the child component, not the <tt CLASS=literal>Panel</tt>. 
There's one exception to this rule: if a component uses the <tt CLASS=literal>LightweightPeer</tt> 
(new to Java 1.1), it cannot be the target of an event. 

<P CLASS=para>
With Java 1.1, events are delivered to whatever listener is associated 
with a contained component. The fact that the component is within a <tt CLASS=literal>Panel</tt> 
has no relevance. 

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch06_01.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch06_03.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Container</td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Insets</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
